package com.xiaolin.util;

import java.util.Calendar;
import java.util.Date;

/**
 * @ClassName TestCalendar
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/9/27
 * @Version 1.0
 */
public class TestCalendar {
    public static void main(String[] args) {
        //日历对象
        Calendar calendar=Calendar.getInstance();
        //获取当前年份
        int weekYear = calendar.getWeekYear();
        System.out.println(weekYear);
        //获取当前时间毫秒数，与Date对象的getTime()方法一样
        long timeInMillis = calendar.getTimeInMillis();
        System.out.println(timeInMillis);
        //获取当前年份的周数
        int weeks = calendar.getWeeksInWeekYear();
        System.out.println(weeks);
        //获取当前时间
        Date time = calendar.getTime();
        System.out.println(time);
    }
}
